package com.biz.primus.ms.depot.api;

import com.biz.primus.common.vo.SpringPageVO;
import com.biz.primus.model.depot.vo.*;
import com.biz.primus.ms.base.api.BaseApiController;
import com.biz.primus.ms.depot.service.EmployeeService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * EmployeeApiController
 *
 * @author JKLiues
 * @date 2017年10月31日
 */
@RestController
@RequestMapping("soa/employeeService")
public class EmployeeApiController extends BaseApiController {
    private final EmployeeService employeeService;

    @Autowired
    public EmployeeApiController(EmployeeService employeeService) {
        this.employeeService = employeeService;
    }

    @GetMapping("findByEmployeeId")
    @ApiOperation("通过员工ID查员工信息")
    public EmployeeVo findByEmployeeId(@ApiParam(value = "员工ID") @RequestParam("employeeId") Long employeeId) {
        return employeeService.findByEmployeeId(employeeId);
    }

    @ApiOperation("根据员工编号查员工信息")
    @GetMapping("findByEmployeeCode")
    public EmployeeVo findByEmployeeCode(@ApiParam(value = "员工编号") @RequestParam("employeeCode") String employeeCode) {
        return employeeService.findByEmployeeCode(employeeCode);
    }

    @ApiOperation("门店分页查询员工")
    @PostMapping("pageResult")
    public SpringPageVO<EmployeeListRespVo> pageResult(EmployeePageReqVo reqVo) {
        return employeeService.pageResult(reqVo);
    }

    @ApiOperation("tms分页查询员工")
    @PostMapping("tmsPageResult")
    public SpringPageVO<EmployeeTmsListRespVo> tmsPageResult(EmployeePageReqVo reqVo) {
        return employeeService.tmsPageResult(reqVo);
    }

    @ApiOperation("根据门店编号查员工")
    @GetMapping("findEmployeesByDepotCode")
    public List<EmployeeVo> findEmployeesByDepotCode(@ApiParam(value = "门店编码") @RequestParam("depotCode") String depotCode) {
        return employeeService.findEmployeesByDepotCode(depotCode);
    }

    @ApiOperation("ERP员工信息推送处理方法")
    @PostMapping("handelErpEmp")
    public void handelIncrEmp(@RequestBody List<IncrEmpReqVo> reqVos) {
        employeeService.handelIncrEmp(reqVos);
    }

    @ApiOperation("获取会员推广数据")
    @PostMapping("getSpreadData")
    public SpringPageVO<EmpSpreadRespVo> getSpreadData(@RequestBody EmpSpreadPageReqVo reqVo) {
        return employeeService.getSpreadData(reqVo);
    }

    @ApiOperation("生成员工二维码")
    @PostMapping("generateQrCode")
    public QrCodeVo generateQrCode(@ApiParam(value = "员工编码") @RequestParam("employeeCode") String employeeCode) {
        return employeeService.generateQrCode(employeeCode);
    }

    @ApiOperation("刷新accessToken")
    @PostMapping("refreshAccessToken")
    public String refreshAccessToken() {
        return employeeService.refreshAccessToken();
    }

    @ApiOperation("通过id查编号")
    @GetMapping("getCodeById")
    public String getCodeById(@ApiParam(value = "员工ID") @RequestParam("employeeId") Long employeeId) {
        return employeeService.getCodeById(employeeId);
    }
}